import 'package:flutter/material.dart';
import 'package:flutter_demo/utils/TokenManager.dart';

class SplashPage extends StatefulWidget {
  @override
  State<SplashPage> createState() {
    return _SplashPage();
  }
}

class _SplashPage extends State<SplashPage> {
  @override
  void initState() {
    super.initState();
    Future.delayed(Duration(microseconds: 500), () {
      initSplash();
    });
  }

  initSplash() async {
    await TokenManager().initSp();
    bool isLogin = TokenManager().getToken().isNotEmpty;
    if (isLogin) {
      Navigator.pushReplacementNamed(context, '/homePage');
    } else {
      Navigator.pushReplacementNamed(context, '/login');
    }
  }

  @override
  Widget build(BuildContext context) {
    return Center(child: Text('闪屏页面'));
  }
}
